package com.yunti.springboot.util;

public class ScoreUtils {

    public static String formatTimeStr(String rawScore){
        if(rawScore.contains(":")){
            if(rawScore.split(":").length == 2){
                String[] strings = rawScore.split(":");
                int min = Integer.parseInt(strings[0]);
                double sec = Double.parseDouble(strings[1]);

                String minStr = "";
                if(min < 10){
                    minStr += "0" + min;
                }else{
                    minStr += min;
                }
                return "00:" + minStr + ":" + sec;
            }
            if(rawScore.split(":").length == 3){
                String[] strings = rawScore.split(":");
                int hour =  Integer.parseInt(strings[0]);
                int min = Integer.parseInt(strings[1]);
                double sec = Double.parseDouble(strings[2]);

                String hourStr = "";
                if(hour < 10){
                    hourStr += "0" + hour;
                }else{
                    hourStr += hour;
                }

                String minStr = "";
                if(min < 10){
                    minStr += "0" + min;
                }else{
                    minStr += min;
                }
                return hourStr + ":" + minStr + ":" + sec;
            }
        }
        return "";
    }
}
